<template>
  <div o-Container>
    <o-list v-bind:source="list.sensorInfo" v-bind="{viewed:view,searched:search}"/>
    <o-dialog v-bind:source="panel.info">
      <template slot="content">
        <o-item v-bind:source="item.sensorInfo" v-bind="{backed:back}"/>
      </template>
    </o-dialog>
  </div>
</template>

<script>
  export default {
    name: "mcs_message_list", /* 这个name暂时不知道用啥用，根据官方文档说的是方便排错的 */
    data() {
      return {
        octopus: this.$parent.octopus,
        list: {
          sensorInfo: {
            data: {
              id: 40, // 菜单表的八爪鱼ID
              cellData: [
                {name: "CompanyID", width: 100, searchKey: "="}, // 所属公司
                {
                  name: "ProjectID",
                  width: 300,
                  searchKey: "=",
                  filterKey: "=",
                  link: [{binding: "CompanyID", mapping: "CompanyID"}]
                },  // 所属项目
                {name: "BuildingID", width: 200, searchKey: "=", link: [{binding: "ProjectID", mapping: "ProjectID"}]},//楼宇
                {name: "FloorID", width: 50, searchKey: "=", link: [{binding: "BuildingID", mapping: "BuildingID"}]},//层数 //根据BuildingID 来筛选
                {name: "BerthID", width: 100, searchKey: "=", link: [{binding: "FloorID", mapping: "FloorID"}]},//层数 //根据BuildingID 来筛选
                {name: "LevelID", width: 70, searchKey: "=", filterKey: "="},//等级
                {name: "RuleID", width: 100, searchKey: "=", link: [{binding: "CompanyID", mapping: "CompanyID"}]},//规则
                {name: "RuleTypeID", width: 80, searchKey: "="},//类型
                {name: "SensorID", width: 200, searchKey: "LIKE"},//传感器
                {name: "SensorCode", width: 150, searchKey: "LIKE"},//传感器
                {name: "SpaceID", width: 70, searchKey: "="},//所属场地
                {name: "SystemModuleID", width: 100, searchKey: "="},//所属系统
                {name: "Title", width: 100, searchKey: "LIKE"},//
                {name: "Content", width: 1000, searchKey: "LIKE"},//
                {name: "Status", width: 100},//状态
                {name: "ProcessorID", width: 70, searchKey: "="},//处理人
                {name: "CreateTime", width: 150},//创建时间
                // {name: "DistributedTime", width: 150},//派单时间
                // {name: "FinishedTime", width: 150},//结束时间
                // {name: "CompletedTime", width: 150},//关闭时间
              ],
            }
          },
        },
        item: {
          sensorInfo: {
            data: {
              id: 40,
              cellData: [
                {name: "CompanyID"}, // 所属公司
                {name: "ProjectID"},  // 所属项目
                {name: "BuildingID"},//楼宇
                {name: "FloorID"},//层数 //根据BuildingID 来筛选
                {name: "BerthID"},//层数 //根据BuildingID 来筛选
                {name: "BerthLevelID"},     // 铺位级别
                {name: "LevelID"},//等级
                {name: "SystemModuleID"},//所属系统
                {name: "RuleTypeID"},//类型
                {name: "RuleID"},//规则
                {name: "SensorCode"},//传感器
                {name: "SensorName"},//传感器
                {name: "Title"},//
                {name: "SpaceID"},//所属场地
                {name: "CreateTime"},//报警时间
                {name: "Content"},//
                {name: "Status"},//状态
                {name: "ProcessorID"},//处理人
                // {name: "DistributedTime"},//派单时间
                // {name: "FinishedTime"},//结束时间
                // {name: "CompletedTime"},//关闭时间
              ],
              height: "300px"
            }
          }
        },
        panel: {
          info: {
            visible: false,
          },
        },
      }
    },
    created() {
      this.init();
    },
    methods: {
      init() {
        let url = this.octopus.vue.$route.path;
        // 主控规则消息列表
        if (url.indexOf("MMS/IoT/SensorRule/MessageList") > 0) {

        }
        // MDM 客户端版本
        else {
          this.octopus.tools.parseCell(this.list.sensorInfo.data, "CompanyID").show = false;
          this.octopus.tools.parseCell(this.list.sensorInfo.data, "ProjectID").show = false;
          this.octopus.tools.parseCell(this.list.sensorInfo.data, "ProjectID").filterValue = this.octopus.passport.project;
          this.octopus.tools.parseCell(this.list.sensorInfo.data, "BuildingID").link = [{mapping: "ProjectID",value:this.octopus.passport.project}]
          // 全部
          if (url.indexOf("MMS/IoT/SensorRule/MessageList") > 0) {

          }
          // 报警
          else if (url.indexOf("MDM/IoT/SensorRule/AlarmList") > 0) {
            this.octopus.tools.parseCell(this.list.sensorInfo.data, "LevelID").filterValue = 4;
          }
          // 预警
          else if (url.indexOf("MDM/IoT/SensorRule/WarnList") > 0) {
            this.octopus.tools.parseCell(this.list.sensorInfo.data, "LevelID").filterValue = 3;
          }
          // 关注
          else if (url.indexOf("MDM/IoT/SensorRule/RemindList") > 0) {
            this.octopus.tools.parseCell(this.list.sensorInfo.data, "LevelID").filterValue = 2;
          }

        }
      },
      search(cell) {
      },
      output(data) {
      },
      view(row) {
        this.item.sensorInfo.data.value = row.ID;
        this.item.sensorInfo.control.load();

        this.panel.info.visible = true;
      },
      back: function () {
        this.panel.info.visible = false;
      }
    },
  }
</script>
